#!/usr/bin/python3
# -*- coding:utf-8 -*-
# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This file is a part of the CANN Open Software.
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# ======================================================================================================================

import os
import numpy as np
import torch
import torch.nn.functional as F

def gen_golden_data_simple():
    dtype = np.float32
    input_shape = [8, 2048]

    input_p = np.random.uniform(0.01, 0.99, input_shape).astype(dtype)
    input_y = np.random.randint(0, 2, input_shape).astype(dtype)
    p_torch = torch.from_numpy(input_p)
    y_torch = torch.from_numpy(input_y)
    golden_torch = F.binary_cross_entropy(p_torch, y_torch, reduction='none')
    golden = golden_torch.numpy().astype(dtype)

    os.system("mkdir -p input")
    os.system("mkdir -p output")
    input_p.astype(dtype).tofile("./input/input_p.bin")
    input_y.astype(dtype).tofile("./input/input_y.bin")
    golden.astype(dtype).tofile("./output/golden.bin")

if __name__ == "__main__":
    gen_golden_data_simple()
